<?php
namespace app\admin\controller;
use think\Controller;
use think\Db;

class Reception extends Controller{
    public function stration(){
     $date=Db::table("park_user")->paginate(5);
     $page = $date->render();
     return view("Reception/reception_show",["bo"=>$date,"page"=>$page]);
    }
    public function reception_show($reception_id){
        $get=$reception_id;
        $date=Db::table("park_user")->where("id=".$get)->select();
        return view("Reception/reception",["bo"=>$date,"reception_id"=>$get]);
    }
    public function reception_delete($reception_id){
        $get=$reception_id;
        $date=Db::table("park_user")->where("id=".$get)->delete();
        if($date){
            $data=Db::table("park_user")->paginate(6);
            $page=$data->render();
            return view('Reception/reception_show',["bo"=>$data,'reception_id'=>$get,"page"=>$page]);

        }else{
            $this->error("删除失败","reception_show","",1);
        }
    }
    public function reception_update($reception_id){
        $get=$reception_id;
        $date=Db::table("park_user")->where("id=".$get)->select();
        return view("Reception/reception_update",["bo"=>$date,"reception_id"=>$get]);
    }
    public function update($reception_id){
        $get=$reception_id;
        $data=[
            'tate'=>$_POST["tate"]
        ];
        if(request()->isPost()){
            $date=Db::table("park_user")->where("id=".$get)->update($data);
            if($date){
                $data=Db::table("park_user")->where("id=".$get)->paginate(5);
                dump($data);
                $page = $data->render();
                $this->redirect("reception_show",["bo"=>$data,"page"=>$page,"reception_id"=>$get]);
            }else{
                $data=Db::table("park_user")->where("id=".$get)->paginate(5);
                $page = $data->render();
                return view("reception_show",["bo"=>$data,"page"=>$page,"reception_id"=>$get]);
            }
        }else{
            $this->error("提交失败","reception_show");
        }
    }

             public function select(){//用户查询

                 $name = $_POST["keywords"];
                 if ($name == "") {//判断name值是否为空
                     $row = Db::name('park_user')->paginate(6);
                 } else {                                                                                           //不否为空进行模糊查询
                 $row = Db::table("User")->where("
                username like '%{$name}'
                or username like '%{$name}'
                or username like '%{$name}%'
                ")->paginate(6);  //查询 细分类的表 找到对应的类名
                 }
                 $page = $row->render();
                 return view('Reception/reception_show',array('bo'=>$row,'page'=>$page));
             }
         public function reception_details($reception_id){
             $get=$reception_id;
             $date=Db::table("park_user")->where("id=".$get)->paginate(5);
             $page = $date->render();
             return view("Reception/reception_details",["bo"=>$date,"page"=>$page]);
       }

}